import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
// import * as actions from './actions'
// import mutations from './mutations.js'
// import lists from './modules/lists'


const store = new Vuex.Store({
  state: {
    count: 0,
    filename: 'name',   
    userInfo: {},         //用户登录时，存储用户基本信息。
    pageId:'home',        //页面标识，用于底部导航高亮显示
    goodsId: 0,           //跟踪用户浏览商品，显示详情
    goodsNow: {},         //存储当前浏览商品详情
    buy:false,             //立即购买的状态
    cartbuy:false,         //购物车中购买的状态
    cartGoodsNum: 0,      //购物车商品数量，不为空时底部导航显示红点
    cartClickList: [],    //购物车中选中商品列表，用于向确认订单页显示
    orderGoodsIds:[],      //购物车选中商品id列表，用于生成订单
    firstAddress:{},      //用户设置默认地址，用于确认订单页
    addressIdx:0,         //默认地址的序号，再次回到页面依然正确显示
    orderbtn: ''          //user页面选中orderbtn的状态

  },
  mutations:{
    increment: state => state.count++,
    decrement: state => state.count--,
    uploadSetName: (state,value) => state.filename = value,

    setOrderbtn: (state,value) => state.orderbtn = value,
    setuserInfo: (state,value) => state.userInfo = value,
    setGoodsId: (state,value) => state.goodsId = value,
    setGoodsNow: (state,value) => state.goodsNow = value,
    setpageId: (state,value) => state.pageId = value,
    setfirstAddress: (state,value) => state.firstAddress = value,
    setaddressIdx: (state,value) => state.addressIdx = value,
    setorderGoodsIds: (state,value) => state.orderGoodsIds = value
  }
})

export default {
  store
}
